package drds.binlog.database_driver.packets.server;

import drds.binlog.common.Authors;
import drds.binlog.database_driver.packets.PacketWithHeaderPacket;
import drds.binlog.database_driver.utils.Bytes;
import drds.common.Author;
import lombok.Getter;
import lombok.Setter;

import java.io.ByteArrayOutputStream;
import java.io.IOException;

@Author(name = Authors.LI_YANG)
public class Reply323Packet extends PacketWithHeaderPacket
{

    @Setter
    @Getter
    public byte[] seed;

    public void fromBytes(byte[] bytes) throws IOException
    {

    }

    public byte[] toBytes() throws IOException
    {
        if (seed == null)
        {
            return new byte[]{(byte) 0};
        } else
        {
            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
            Bytes.writeNullTerminated(byteArrayOutputStream, seed);
            return byteArrayOutputStream.toByteArray();
        }
    }

}
